package org.example.springbirthday.mapper;

import org.apache.ibatis.annotations.*;
import org.example.springbirthday.model.Notice;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 九转苍翎
 * Date: 2025/8/13
 * Time: 21:41
 */
@Mapper
public interface NoticeMapper {

    @Select("select * from notice where id = #{id}")
    Notice getNoticeById(Integer id);

    @Select("select * from notice where user_id = #{userId}")
    List<Notice> getNoticeByUserId(Integer userId);

    @Insert("insert into notice (user_id,user_name,title,context,publish_date_status) values (#{userId},#{userName},#{title},#{context},#{publishDateStatus})")
    Integer publish(Notice notice);

    @Select("select * from notice")
    List<Notice> getNoticeList();

    @Update("update notice set title = #{title},context = #{context} where id = #{id}")
    Integer update(Notice notice);

    @Delete("delete from notice where id = #{id}")
    Integer delete(Integer id);

    @Update("update notice set user_name = #{userName}")
    Integer updateUserName(Notice notice);
}
